using Microsoft.AspNetCore.Mvc;
using Read.Services;

namespace Read.Web.Controllers
{
    /// <summary>
    /// 文章管理
    /// </summary>
    public class ArchivesController : BaseController
    {
        /// <summary>
        /// 文章首页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            var alist = new ArchivesService();
            //ViewBag.ArchivesList = alist.getArchivesList();
            var archivesList = alist.getArchivesList();
            ViewBag.Title = "Archives";
            return View(archivesList);
        }

        /// <summary>
        /// 文章明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Show(int id)
        {
            var a = new ArchivesService();
            var archives = a.getArchives(id);
            ViewBag.Title = archives.Title;
            ViewBag.Count = archives.Content.Length;
            return View(archives);
        }
    }
}